package com.tianji.remark.task;

import com.tianji.remark.domain.dto.LikeRecordFormDTO;
import com.tianji.remark.service.ILikedRecordService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;
@Slf4j
@Component
@RefreshScope
@RequiredArgsConstructor
public class LikedTimesCheckTask {
    private static final List<String> BIZ_TYPES = List.of("QA", "NOTE");
    private static final int MAX_LIKED_TIMES = 100;
    private final ILikedRecordService likedRecordService;
    /**
     * 定时检测点赞数并发送业务方持久化消息
     */
    @Scheduled(fixedDelay = 20000)
    public void checkLikedTimes() {
        for (String bizType : BIZ_TYPES) {
            log.warn("当前处理任务数：" + MAX_LIKED_TIMES);
            likedRecordService.readLikedTimesAndSendMessage(bizType, MAX_LIKED_TIMES);
        }
    }
}
